/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.amkai.aes.aesws;

import com.amkai.aes.aescommon.Version;
import com.amkai.aes.aescommon.service.binary.job.Job;
import com.amkai.aes.server.session.Connection;
import com.amkai.aes.server.session.ServiceSessionManager;
import com.amkai.aes.webservice.binary.JobManager;
import com.amkai.common.base.streams.SerializerUtils;
import java.io.Serializable;

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;

/**
 *
 * @author Miskolczi Péter
 */
@WebService()
public class aesws {

	@Resource private WebServiceContext wsContext;
	
	/**
     * Web service operation
     */
    @WebMethod(operationName = "processJob")
    public byte[] processJob(@WebParam(name = "jobArray")
    byte[] jobArray) throws Throwable {
    	 MessageContext mc = wsContext.getMessageContext();
         HttpSession session = ((HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
         // Get a session property "counter" from context
         if (session == null)
             throw new WebServiceException("No session in WebServiceContext");
         
         return AesJobExecutor.executeJob(session, jobArray);
    }

    /**
     * Web service operation
     */
    @WebMethod(operationName = "getVersion")
    public String getVersion() {
        return Version.AO_CODE_VERSION_MAJOR_MINOR_RELEASE_BUILD;
    }

}
